#coding: utf-8
class CulturalHeritage::IncidencesAvatar < ActiveRecord::Base
   has_attached_file :avatar
   default_scope where("deleted = 0")

  def self.count_incidence_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_incidences_avatars.incidence = ? and (cultural_heritage_incidences_avatars.deleted = ?) ",id,0],:select=>"count(*) as 'incidences_avatars'")[0].incidences_avatars.to_i
  end
end
